from selenium.webdriver.common.by import By

from common.Utils import BlogDriver


class BlogDetailsTest:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://127.0.0.1:9580/index.html"
        self.driver = BlogDriver.driver
        self.driver.get(self.url)

    def DetailsEleTest(self):
        self.driver.find_element(By.CSS_SELECTOR,"#artical-items-body > div:nth-child(1) > div > div.col > div.text-truncate > a > strong").click()
        #“发私信”是否可以点击出现弹窗
        self.driver.find_element(By.CSS_SELECTOR,"#btn_details_send_message").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_modal > div > div > div.modal-header > h5")
        BlogDriver.getScreeShot()
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_modal > div > div > div.modal-header > button").click()

        #回复编辑组件是否可以正常使用
        self.driver.find_element(By.CSS_SELECTOR,"#article_details_reply > div.editormd-toolbar > div > ul > li:nth-child(7) > a > i").click()
        self.driver.find_element(By.CSS_SELECTOR,"#details_btn_article_reply").click()
        BlogDriver.getScreeShot()

        #”点赞“是否可以点击进行点赞
        self.driver.find_element(By.CSS_SELECTOR,"#details_btn_like_count").click()
        BlogDriver.getScreeShot()

    def SendMessagePopupWindowTest(self):
        #输入消息是否可以发送
        self.driver.find_element(By.CSS_SELECTOR,"#btn_details_send_message").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_receive_content").send_keys("haha")
        self.driver.find_element(By.CSS_SELECTOR,"#btn_index_send_message").click()
        BlogDriver.getScreeShot()

        #不输入消息是否可以发送
        self.driver.find_element(By.CSS_SELECTOR,"#btn_details_send_message").click()
        self.driver.find_element(By.CSS_SELECTOR,"#btn_index_send_message").click()
        BlogDriver.getScreeShot()

        #“取消”是否可以点击关闭弹窗
        self.driver.find_element(By.CSS_SELECTOR,"#btn_details_send_message").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_receive_cancel").click()
        self.driver.find_element(By.CSS_SELECTOR,"#details_article_title")
        BlogDriver.getScreeShot()

        #关闭按钮是否可以点击关闭弹窗
        self.driver.find_element(By.CSS_SELECTOR,"#btn_details_send_message").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_modal > div > div > div.modal-header > button").click()
        self.driver.find_element(By.CSS_SELECTOR,"#details_article_title")
        BlogDriver.getScreeShot()

